package com.youpai.platform.chat.service.config;

import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

import java.util.concurrent.*;

/**
 * @date: 2022/5/14 14:21
 * @author: Anna
 * @version: 1.0
 * @description: 线程池配置类
 */
@Configuration
public class ThreadPoolConfig {

    @Bean(name = "syncChatThreadPool")
    public ExecutorService initSyncChatThreadPool() {
        ThreadFactory threadFactory = new CustomizableThreadFactory("syncChat-");
        return new ThreadPoolExecutor(10, 20, 2000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1000),threadFactory);
    }
}
